package zhuyun.code.launcheractivity.utils

import android.os.Message
import android.util.Log
import java.lang.StringBuilder
import java.nio.charset.Charset
import java.security.MessageDigest
import kotlin.experimental.and

/**
 * @author: Administrator
 * @date: 2021/11/18
 */
object EncoderData {
    fun encoderByMd5(string:String):String{
        val hash = MessageDigest.getInstance("MD5").digest(string.toByteArray())
        val hex = StringBuilder(hash.size*2)
        for(byte in hash){

            val i = byte.toInt() and 0xFF
            var hexString = Integer.toHexString(i)
            Log.d("zzz",hexString)
            if(hexString.length == 1){
                hexString = "0$hexString"
            }
            Log.d("zzz",hexString)
            hex.append(hexString)
        }
        return hex.toString()
    }
}